﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace BanHangCshap.Class
{
    class NhomChucNang:Database
    {
        #region ***** Fields & Properties ***** 
		private string _manhomcn;
		public string manhomcn
		{ 
			get 
			{ 
				return _manhomcn;
			}
			set 
			{ 
				_manhomcn = value;
			}
		}
		private string _tennhomcn;
		public string tennhomcn
		{ 
			get 
			{ 
				return _tennhomcn;
			}
			set 
			{ 
				_tennhomcn = value;
			}
		}
		#endregion

		#region ***** Init Methods ***** 
		public NhomChucNang()
		{
		}
		public NhomChucNang(string manhomcn)
		{
			this.manhomcn = manhomcn;
		}
		public NhomChucNang(string manhomcn, string tennhomcn)
		{
			this.manhomcn = manhomcn;
			this.tennhomcn = tennhomcn;
		}
		#endregion
        public Boolean themNhomChucNang()
        {
            string sql = " insert into NhomChucNang(manhomcn,tennhomcn) values ('" + manhomcn + "', N'" + tennhomcn + "')";
            return executeQuery(sql);
        }
        public Boolean suaNhomChucNang()
        {
            string sql = "update NhomChucNang set tennhomcn = N'" + tennhomcn + "' where manhomcn = '" + manhomcn + "'";
            return executeQuery(sql);
        }
        public Boolean xoaNhomChucNang(string manhomcn)
        {
            string sql = "delete NhomChucnang where manhomcn = '" + manhomcn + "'";
            return executeQuery(sql);
        }
        public DataTable layDSNhomChucNang()
        {
            string sql = "select manhomcn,tennhomcn,'' as macn from NhomChucNang order by manhomcn ";
            return getDataTable(sql);
        }
        public DataTable layDSChucNang(string manhomcn)
        {
            string sql = "select * from ChucNang where manhomcn = '" + manhomcn + "'";
            return getDataTable(sql);
        }

    }
}
